package Component

import (
	"golang.org/x/text/encoding/simplifiedchinese"
)

const UserName = "UserName"
const PassWord = "PassWord"
const CMD = "CMD"

const RmoteServer = "RemoteServer"
const RmotePath = "RemotePath"
const LocalPath = "LocalPath"

const RmoteDir = "RemoteDir"
const LocalDir = "LocalDir"

const RemoteCurrentDir = "RemoteCurrentDir"

type Charset string

const (
	UTF8    = Charset("UTF-8")
	GB18030 = Charset("GB18030")
)

func ConvertByte2String(byte []byte, charset Charset) string {
	var str string
	switch charset {
	case GB18030:
		decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
		str = string(decodeBytes)
	case UTF8:
		fallthrough
	default:
		str = string(byte)
	}

	return str
}

type IComponent interface {
	Run() (err error)
	SetParameter(name string, parameter string)
}
